home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00400_Search Utilities.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  6.3 KB  |  219 lines

  1. global oIndexScroller, gGlobalStepCount, gLocalStepCount, gInputField, gModeState, gAlphaState, gCurrEntryAttrib, gNewSetIsHereF, gchunksize, gFirstHotWord, gEpisFTchunksizeK, oIndexMediator, gTheFTword, gFTsearchscope, gModeNameLU, gNumofHits, gStatusField, gStardateLU, gStardLUlistSize, gFTstartSND, gESstartSND, gIndexSND, oTextScroller, gIndxScrollFldK, gTheMseWord, gActiveResTopWin, gAposCurlyQ, gBeginCurlyQ, gEndCurlyQ, gComputerTypeK, gdescfield
  2.  
  3. on hFilterSearchChars pTheChars
  4.   if pTheChars = EMPTY then
  5.     hReportStatus("Sorry, I can't find that.")
  6.     hearit(gNopeSND)
  7.     abort()
  8.   end if
  9.   if gModeState = #CHRO then
  10.     if char 1 of pTheChars = "‚Ä¢" then
  11.       if char 2 of pTheChars = " " then
  12.         set lk to string(18)
  13.       else
  14.         set lk to string(24)
  15.       end if
  16.     else
  17.       set lk to char 1 to 2 of pTheChars
  18.       if value(lk) > 23 then
  19.         set lk to string(24)
  20.       end if
  21.     end if
  22.   else
  23.     if gModeState = #EPIS then
  24.       set lk to char 2 of pTheChars
  25.     else
  26.       if gModeState = #FoundSet then
  27.         set Lchar to char 1 of pTheChars
  28.         if Lchar = "‚Ä¢" then
  29.           set lk to string(18)
  30.         else
  31.           if (value(Lchar) >= 1) and (value(Lchar) <= 9) then
  32.             set Lk2v to value(char 2 of pTheChars)
  33.             if (value(Lchar) >= 0) and (value(Lchar) <= 9) then
  34.               set lk to char 1 to 2 of pTheChars
  35.             end if
  36.           else
  37.             if (Lchar = "‚Äú") or (Lchar = " ") then
  38.               set lk to char 2 of pTheChars
  39.             else
  40.               set lk to Lchar
  41.             end if
  42.           end if
  43.         end if
  44.         set lk to hCapitalize(lk)
  45.       else
  46.         if (gModeState = #Resources) or (gModeState = #TOPICS) then
  47.           set lk to "A"
  48.         else
  49.           set lk to hCapitalize(char 1 of pTheChars)
  50.         end if
  51.       end if
  52.     end if
  53.   end if
  54.   return lk
  55. end
  56.  
  57. on hIsaStardate pNumber
  58.   if not objectp(gStardateLU) then
  59.     return(void)
  60.   end if
  61.   set Lmyloc to findPosNear(gStardateLU, value(pNumber))
  62.   if Lmyloc <= gStardLUlistSize then
  63.     return getAt(gStardateLU, Lmyloc)
  64.   else
  65.     return(void)
  66.   end if
  67. end
  68.  
  69. on hInitCurlyQ
  70.   if gComputerTypeK = #WIN then
  71.     set gBeginCurlyQ to numToChar(65427)
  72.     set gEndCurlyQ to numToChar(65428)
  73.     set gAposCurlyQ to numToChar(65426)
  74.   else
  75.     set gBeginCurlyQ to numToChar(210)
  76.     set gEndCurlyQ to numToChar(211)
  77.     set gAposCurlyQ to numToChar(213)
  78.   end if
  79. end
  80.  
  81. on hIsanEpisode pChunk, pthisword
  82.   if pChunk contains gBeginCurlyQ then
  83.     set Lsize to the number of words in pChunk
  84.     set Loffset to pthisword - gEpisFTchunksizeK
  85.     set Lstart to 0
  86.     repeat with vWordCount = pthisword down to Loffset
  87.       if vWordCount = pthisword then
  88.         set vHoldword to word vWordCount of field gdescfield
  89.         set vHoldword to hZapEnd(vHoldword, charToNum(gEndCurlyQ))
  90.       else
  91.         set vHoldword to word vWordCount of field gdescfield
  92.       end if
  93.       if vHoldword contains gBeginCurlyQ then
  94.         set Lstart to vWordCount
  95.         exit repeat
  96.       end if
  97.     end repeat
  98.     if Lstart = 0 then
  99.       return 0
  100.     end if
  101.     set Loffset to pthisword + gEpisFTchunksizeK
  102.     repeat with vWordCount = pthisword to Loffset
  103.       if vWordCount = pthisword then
  104.         set vHoldword to word vWordCount of field gdescfield
  105.         set vHoldword to hZapEnd(vHoldword, charToNum(gBeginCurlyQ))
  106.       else
  107.         set vHoldword to word vWordCount of field gdescfield
  108.       end if
  109.       if char length(vHoldword) of vHoldword = gEndCurlyQ then
  110.         set Lend to vWordCount
  111.         exit repeat
  112.       end if
  113.     end repeat
  114.     if Lend = 0 then
  115.       return 0
  116.     end if
  117.     set Lgotcha to word Lstart to Lend of field gdescfield
  118.     if word 1 of Lgotcha starts "(" then
  119.       delete char 1 of word 1 of Lgotcha
  120.     end if
  121.     set vCheckingEpis to word Lend + 1 of field gdescfield
  122.     if (vCheckingEpis contains "TNG") or (vCheckingEpis contains "DS9") or (vCheckingEpis contains "TOS") or (vCheckingEpis contains "VGR") then
  123.       return Lgotcha
  124.     else
  125.       return 0
  126.     end if
  127.   else
  128.     if pChunk contains "(Star" then
  129.       set Lsize to the number of words in pChunk
  130.       set Loffset to pthisword - gEpisFTchunksizeK
  131.       set Lstart to 0
  132.       repeat with vWordCount = pthisword down to Loffset
  133.         set vHoldword to word vWordCount of field gdescfield
  134.         if vHoldword contains "(Star" then
  135.           set Lstart to vWordCount
  136.           exit repeat
  137.         end if
  138.       end repeat
  139.       if Lstart = 0 then
  140.         return 0
  141.       end if
  142.       set Loffset to pthisword + gEpisFTchunksizeK
  143.       repeat with vWordCount = pthisword to Loffset
  144.         set vHoldword to word vWordCount of field gdescfield
  145.         if char length(vHoldword) - 1 of vHoldword = ")" then
  146.           set Lend to vWordCount
  147.           exit repeat
  148.         end if
  149.       end repeat
  150.       if Lend = 0 then
  151.         return 0
  152.       end if
  153.       set Lgotcha to word Lstart to Lend of field gdescfield
  154.       set vLastWord to word the number of words in Lgotcha of Lgotcha
  155.       set vLastWord to hZapEnd(vLastWord, 46)
  156.       set vLastWord to hZapEnd(vLastWord, 41)
  157.       set Lgotcha to word Lstart to Lend - 1 of field gdescfield && vLastWord
  158.       if word 1 of Lgotcha starts "(" then
  159.         delete char 1 of word 1 of Lgotcha
  160.       end if
  161.       set Lgotcha to numToChar(32) & Lgotcha
  162.       return Lgotcha
  163.     else
  164.       return 0
  165.     end if
  166.   end if
  167. end
  168.  
  169. on hZapBegin vEntry, vCharacter
  170.   repeat while charToNum(char 1 of vEntry) = vCharacter
  171.     delete char 1 of vEntry
  172.   end repeat
  173.   return vEntry
  174. end
  175.  
  176. on hZapEnd vEntry, vCharacter
  177.   if charToNum(char length(vEntry) of vEntry) = vCharacter then
  178.     delete char length(vEntry) of vEntry
  179.   end if
  180.   return vEntry
  181. end
  182.  
  183. on hZapThroughOut vEntry, vCharacter
  184.   repeat with n = 1 to length(vEntry)
  185.     if charToNum(char n of vEntry) = vCharacter then
  186.       delete char n of vEntry
  187.     end if
  188.   end repeat
  189.   return vEntry
  190. end
  191.  
  192. on hFillInputField pWithMe
  193.   put hcleanup(pWithMe) into field gInputField
  194.   hilite char 999 of field gInputField
  195. end
  196.  
  197. on hGetMode pNtry
  198.   set pNtry to string(pNtry)
  199.   set Lc1 to char 1 of pNtry
  200.   if hIsaQuote(Lc1) or (Lc1 = " ") then
  201.     return #EPIS
  202.   else
  203.     if hIsaRomanDate(pNtry) then
  204.       return #CHRO
  205.     else
  206.       if Lc1 = "‚Ä¢" then
  207.         return #CHRO
  208.       else
  209.         return #ENCY
  210.       end if
  211.     end if
  212.   end if
  213. end
  214.  
  215. on hDetectMode pNtry
  216.   hSetMode(#ENCY)
  217.   return 1
  218. end
  219.